<template>
  <div>
    <van-tabs v-model="active">
      <van-tab title="表单信息">
        <div id="HandlerPage">
          <p class="title">
            <span class="line"></span>
            户主信息
          </p>
          <div class="from">
            <van-field readonly v-model="form.HOUSEAPPLICANT" label="姓名" />
            <van-field readonly v-model="form.APPLYPHONE" label="联系电话" />
            <van-field readonly v-model="form.SEX == 3 ? '男' : '女'" label="性别" />
            <van-field readonly v-model="form.BUILDREASON_DICNAME" label="建房理由" />
            <van-field readonly v-model="form.CERTIFICATECODE" label="身份证号码" />
            <van-field readonly v-model="form.PERMANENTADDR" label="家庭地址" />
          </div>
          <p class="title">
            <span class="line"></span>
            家庭成员信息
          </p>
          <FramlyData :Isshowbutton="false" :rowData="form" />
          <!-- <lianjianrenGTXX :rowData="form" /> -->
          <p class="title">
            <span class="line"></span>
            原宅基地及农房情况
          </p>
          <div>
            <van-field readonly v-model="formDataYZDJ.ZJDMJ" label="宅基地面积(m²)" />
            <van-field readonly v-model="formDataYZDJ.JZMJ" label="建筑面积(m²)" />
            <van-field v-if="formDataYZDJ.XZJDCZQK === '37'" readonly v-model="formDataYZDJ.XZJDCZQK = '保留'" label="现宅基地处置情况" />
            <van-field v-else-if="formDataYZDJ.XZJDCZQK === '38'" readonly v-model="formDataYZDJ.XZJDCZQK = '退给村集体'" label="现宅基地处置情况" />
            <van-field v-else-if="formDataYZDJ.XZJDCZQK === '39'" readonly v-model="formDataYZDJ.XZJDCZQK = '其他'" label="现宅基地处置情况" />
            <van-field readonly v-model="form.XZJDCZQK" label="现宅基地处置情况" />
            <van-field v-if="formDataYZDJ.XZJDCZQK === '保留' || formDataYZDJ.XZJDCZQK == '37'" readonly v-model="formDataYZDJ.XZJDCZQK_BL"
              label="保留面积(m²)" />
            <van-field v-if="formDataYZDJ.XZJDCZQK === '其他' || formDataYZDJ.XZJDCZQK == '39'" readonly v-model="formDataYZDJ.XZJDCZQK_QT"
              label="其他" />
            <van-field readonly v-model="formDataYZDJ.QSZSH" label="权属证书号" />
            <!-- <van-field readonly v-model="formDataYZDJ.XZJDCZQK_JS" label="间数" /> -->
            <van-field  clickable name="picker"
                    :value="formDataYZDJ.XZJDCZQK_JS | inUseName(ENUM.TXJSARR1)" label="间数" placeholder="请选择间数"
                    @click="ENUM.TXJS1 = true" />
                  <van-popup v-model="ENUM.TXJS1" position="bottom" get-container="#popup">
                    <van-picker show-toolbar :columns="ENUM.TXJSARR1" value-key="DICNAME"
                      @cancel="ENUM.TXJS1 = false" />
                  </van-popup>
            <van-field readonly v-model="formDataYZDJ.XZJDCZQK_MJ" label="面积(m²)" />
          </div>
          <p class="title">
            <span class="line"></span>
            拟批准宅基地信息及建房情况
          </p>
          <div>
            <van-field readonly v-model="formTKXX.HOMESTEADAREA" label="宅基地面积(m²)" />
            <van-field readonly v-model="formTKXX.HOUSEFLOORAREA" label="房基占地面积(m²)" />
            <van-field readonly v-model="formTKXX.CONSTRUCITONADDRESS" label="地址" />
            <van-field readonly v-model="formTKXX.EAST" label="东至" />
            <van-field readonly v-model="formTKXX.SOUTH" label="南至" />
            <van-field readonly v-model="formTKXX.WEST" label="西至" />
            <van-field readonly v-model="formTKXX.NORTH" label="北至" />
            <van-field v-if="formTKXX.YDLX === '15'" readonly v-model="formTKXX.YDLX = '建设用地'" label="地类" />
            <van-field v-else-if="formTKXX.YDLX === '16'" readonly v-model="formTKXX.YDLX = '未利用地'" label="地类" />
            <van-field v-else-if="formTKXX.YDLX === '17'" readonly v-model="formTKXX.YDLX = '农用地'" label="地类" />
            <van-field v-else-if="formTKXX.YDLX === '255'" readonly v-model="formTKXX.YDLX = '宅地基'" label="地类" />
            <van-field v-else readonly v-model="formTKXX.YDLX" label="地类" />
            <van-field readonly v-if="formTKXX.APPLYTYPE == '12'" v-model="formTKXX.APPLYTYPE = '原址翻建'" label="性质" />
            <van-field readonly v-else-if="formTKXX.APPLYTYPE === '13'" v-model="formTKXX.APPLYTYPE = '改扩建'" label="性质" />
            <van-field readonly v-else-if="formTKXX.APPLYTYPE === '14'" v-model="formTKXX.APPLYTYPE = '异址新建'"
              label="性质" />
            <van-field readonly v-else v-model="formTKXX.APPLYTYPE" label="性质" />
            <!-- <van-field readonly v-model="formTKXX.BUILDSTOREY" label="建筑层数(层)" /> -->
            <van-field readonly clickable name="picker"
                      :value="formTKXX.BUILDSTOREY | inUseName(ENUM.YDLXARR1)" label="建筑层数" placeholder="请填写建筑层数"
                      @click="ENUM.YDLX1 = true" />
                    <van-popup v-model="ENUM.YDLX1" position="bottom" get-container="#popup">
                      <van-picker show-toolbar :columns="ENUM.YDLXARR1" value-key="DICNAME"
                        @cancel="ENUM.YDLX1 = false" />
                    </van-popup>
            <van-field readonly v-model="formTKXX.BUILDAREA" label="住房建筑面积(m²)" />
            <van-field readonly v-model="formTKXX.BUILDHEIGHT" label="檐口高度(m)" />
            <van-field readonly v-model="formTKXX.DPGD" label="地坪高度(m)" />
            <van-field readonly v-model="formTKXX.JZZGD" label="建筑总高度(m)" />

          </div>
          <p class="title">
            <span class="line"></span>
            附件材料
          </p>
          <upLoad id="upLoad1" :ISDelete="false" :isReadOnly="false" :rowData="form" :FJData="fileCUN"
            :CUNID="form.ROW_GUID" :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
            :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
          <p class="title">
            <span class="line"></span>
            补正文件
          </p>
          <p class="title">
            <span class="line"></span>
            上传附件
          </p>
          <upLoad id="upLoad1" :ISDelete="false" :rowData="form" :isReadOnly="false" :FJData="fileCUN1"
            :CUNID="form.ROW_GUID" :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
            :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
          <p class="title">
            <span class="line"></span>
            位置图
          </p>
          <upLoad id="upLoad1" :ISDelete="false" :isReadOnly="false" :rowData="form" :FJData="fileCUN2"
            :CUNID="form.ROW_GUID" :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
            :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
          <div v-if="pageType.indexOf('规划') !== -1">
            <p class="title">
              <span class="line"></span>
              规划范围
            </p>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field readonly clickable name="picker"
                v-model="!form.GHFWLX ? '' : form.GHFWLX == 66 ? '乡、村规划区内' : '城镇建设用地范围'" label="规划范围类型" placeholder="请选择"
                @click="showPicker = true" />
              <van-popup v-model="showPicker" position="bottom" get-container="#popup">
                <van-picker show-toolbar :columns="columns2" @confirm="onConfirm1" @cancel="showPicker = false" />
              </van-popup>
            </div>
            <!-- <p class="title">
          <span class="line"></span>
          宅基地坐落平面位置图
        </p>
        <div>
          <van-uploader v-model="fi2leList" @click-upload="getList()" :before-delete="delectFile" :max-size="100 * 1024" @oversize="onOversize" accept="image/jpeg, image/png, image/jpg, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, application/pdf" :after-read="afterRead" :max-count="4" />
        </div>-->
          </div>
          <div v-if="pageType.indexOf('农房') !== -1">
            <p class="title">
              <span class="line"></span>
              工匠信息
            </p>
            <div>
              <van-field readonly v-model="GJXX.XM" label="姓名" />
              <van-field readonly v-model="GJXX.TELPHONE" label="手机号" />
              <van-field readonly v-model="GJXX.GJXJ" label="工匠星级" />
              <van-field readonly v-model="GJXX.RZSJ" label="入驻时间" />
              <van-field readonly v-model="GJXX.ZSBH" label="证书编号" />
              <van-field readonly v-model="GJXX.SCGZ" label="擅长工种" />
              <van-field readonly v-model="GJXX.ZYXX" label="职业信息" />
            </div>
            <p class="title" v-if="TJBH != 158">
              <span class="line"></span>
              图集表
            </p>

            <div v-if="TJBH != 158">
              <p style="padding:10px 0 0 10px">
                <van-button size="small" type="info" @click="seeAtlas()">查看图集信息</van-button>
                <!-- <van-button size="small" type="info" @click="selectAtlas()">选择通用图集信息</van-button> -->
              </p>
              <van-field readonly v-model="GJXX.TJLX_DICNAME" label="图集类型" />
              <van-field readonly v-model="GJXX.TJBH" label="图集编号" />
              <van-field readonly v-model="GJXX.TJMC" label="图集名称" />
              <van-field readonly v-model="GJXX.JZFG" label="建筑风格" />
              <van-field readonly v-model="GJXX.JZCS" label="建筑层数" />
              <van-field readonly v-model="GJXX.DJJC" label="地基基础" />
              <!-- <van-field readonly v-model="GJXX.IF_DSFSJTZ == '5' ? '是' : '否'" label="是否第三方设计图纸" />
          <van-field readonly v-model="GJXX.STRUCTURETYPE_DICNAME" label="结构类型" /> -->
            </div>

          </div>
          <!-- 当tjlx=158是选择的第三方图集，镇街可以修改第三方图集，否则只读 -->
          <div v-if="TJBH == 157 || TJBH == 158 || TJBH == null">
            <p class="title">
              <span class="line"></span>
              图集信息
            </p>
            <div>
              <van-field readonly :value="TJData.TJLX == '158' ? '第三方设计图集' : '通用图集'" label="图集类型" />
              <van-field readonly v-model="TJData.TJBH" label="图集编号" />
              <van-field v-model="TJData.TJMC" label="图集名称" />
              <van-field v-model="TJData.JZFG" label="建筑风格" />
              <van-field v-model="TJData.DJJC" label="地基基础" />
              <van-field v-model="TJData.JZCS" label="建筑层数(层)" />
              <van-field v-model="TJData.JZFG" label="建筑风格" />
              <div style="border-bottom: 1px solid #ebedf0;padding: 15px">
                <p style="font-size: 14px;font-weight: bold;line-height: 5vh;color: #646566;">图集示例图</p>
                <div>
                  <!-- <van-uploader @click-upload="getList()" :after-read="afterRead" :before-delete="delectFile"
                v-model="fileList" multiple /> -->
                  <img v-if="AtlasData.suolueFileId" width="100%" :src="baseurlid + AtlasData.suolueFileId" alt />
                  <img v-else width="100%" :src="baseurlid + AtlasData.fileUrl" alt />
                  <img width="100%" v-if="!AtlasData.suolueFileId"
                    src="https://nfzjszlb.jst.zj.gov.cn/tyzcpt/api/upload/oss/preview?fileId=3e7acb97b640411a9ce06017e7c12964"
                    alt="" />
                </div>
              </div>
              <div style="border-bottom: 1px solid #ebedf0;padding: 15px;height: 15vh;">
                <p style="font-size: 14px;font-weight: bold;line-height: 5vh;color: #646566;">图集文件(pdf)</p>
                <div style="line-height:10vh;">
                  <el-upload :http-request="uploadFilepdf" style="float: right" class="avatar-uploader"
                    action="https://jsonplaceholder.typicode.com/posts/" :show-file-list="false"
                    :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
                    <p v-if="tjwjpdf" style="float: left" class="avatar" @click="openUrl()">
                      {{ tjwjpdf.fileName }}
                    </p>
                    <el-button v-else size="mini" type="primary">点击上传pdf</el-button>
                  </el-upload>
                </div>
              </div>
              <div style="border-bottom: 1px solid #ebedf0;padding: 15px;height: 15vh;">
                <p style="font-size: 14px;font-weight: bold;line-height: 5vh;color: #646566;">图集文件(cad)</p>
                <div style="line-height:10vh;">
                  <el-upload :http-request="uploadFilecad" style="float: right" class="avatar-uploader"
                    action="https://jsonplaceholder.typicode.com/posts/" :show-file-list="false"
                    :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
                    <p v-if="tjwjcad" style="float: left" class="avatar">
                      {{ tjwjcad }}
                    </p>
                    <el-button v-else size="mini" type="primary">点击上传cad</el-button>
                  </el-upload>
                </div>
                <div>

                </div>
              </div>
            </div>
          </div>

          <p class="title">
            <span class="line"></span>
            镇街部门审核信息表
          </p>
          <div v-if="pageType === '资格审核经办人'">
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field readonly clickable name="picker"
                v-model="!form.ZJZGSHJG ? '' : form.ZJZGSHJG == 48 ? '拟通过' : '不通过'"
                :label="'镇街' + pageType.substring(0, 4) + '(' + pageType.substring(pageType.length - 3) + ')'"
                placeholder="请选择" @click="showPicker1 = true" />
            </div>
            <van-popup v-model="showPicker1" position="bottom" get-container="#popup">
              <van-picker show-toolbar :columns="columns1" @confirm="onConfirm" @cancel="showPicker1 = false" />
            </van-popup>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field type="textarea" rows="3" v-model="form.YJ"
                :label="'镇街' + pageType.substring(0, 4) + '结论(' + pageType.substring(pageType.length - 3) + ')'"
                placeholder="请输入" />
            </div>
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ userName }}</span>
              <span>{{ getDate() }}</span>
            </div>
            <van-field readonly v-model="!form.ZJZGSH ? '' : form.ZJZGSH == 9 ? '拟同意' : '不同意'" label="镇街资格审核(负责人)" />
            <van-field readonly type="textarea" rows="3" v-model="form.ZJZGSHYJFZR" label="镇街资格审核结论(负责人)" />
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ form.ZJZGSHR2 }}</span>
              <span>{{ form.ZJZGSHSJ2 ? form.ZJZGSHSJ2.split(" ")[0] : "" }}</span>
            </div>
          </div>
          <div v-if="pageType === '资格审核负责人'">
            <van-field readonly v-model="!form.ZJZGSHJG ? '' : form.ZJZGSHJG == 48 ? '拟通过' : '不通过'" label="镇街资格审核(经办人)" />
            <van-field readonly type="textarea" rows="3" v-model="form.YJ" label="镇街资格审核结论(经办人)" />
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ form.ZJZGSHR }}</span>
              <span>{{ form.ZJZGSHSJ ? form.ZJZGSHSJ.split(" ")[0] : "" }}</span>
            </div>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field readonly clickable name="picker" v-model="!form.ZJZGSH ? '' : form.ZJZGSH == 9 ? '拟同意' : '不同意'"
                :label="'镇街' + pageType.substring(0, 4) + '(' + pageType.substring(pageType.length - 3) + ')'"
                placeholder="请选择" @click="showPicker1 = true" />
            </div>
            <van-popup v-model="showPicker1" position="bottom" get-container="#popup">
              <van-picker show-toolbar :columns="columns4" @confirm="onConfirm" @cancel="showPicker1 = false" />
            </van-popup>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field type="textarea" rows="3" v-model="form.ZJZGSHYJFZR"
                :label="'镇街' + pageType.substring(0, 4) + '结论(' + pageType.substring(pageType.length - 3) + ')'"
                placeholder="请输入" />
            </div>
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ userName }}</span>
              <span>{{ getDate() }}</span>
            </div>
          </div>
          <div v-if="pageType === '规划审核经办人'">
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field readonly clickable name="picker"
                v-model="!form.GHJBRJG ? '' : form.GHJBRJG == 48 ? '拟通过' : '不通过'" :label="'镇街' +
                  pageType.substring(0, 4) +
                  '(' +
                  pageType.substring(pageType.length - 3) +
                  ')'
                  " placeholder="请选择" @click="showPicker1 = true" />
            </div>
            <van-popup v-model="showPicker1" position="bottom" get-container="#popup">
              <van-picker show-toolbar :columns="columns1" @confirm="onConfirm" @cancel="showPicker1 = false" />
            </van-popup>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field type="textarea" rows="3" v-model="form.GHYJJBR" :label="'镇街' +
                pageType.substring(0, 4) +
                '结论(' +
                pageType.substring(pageType.length - 3) +
                ')'
                " placeholder="请输入" />
            </div>
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ userName }}</span>
              <span>{{ getDate() }}</span>
            </div>
            <van-field readonly v-model="!form.CS ? '' : form.CS == 9 ? '拟同意' : '不同意'" label="镇街规划审核(负责人)" />
            <van-field readonly type="textarea" rows="3" v-model="form.GHFZR" label="镇街规划审核结论(负责人)" />
            <div style="text-align: right;font-size: 14px;">
              <span style="margin-right: 10px">{{ form.ZJGHSHR2 }}</span>
              <span>{{ form.ZJGHSHSJ2 ? form.ZJGHSHSJ2.split(" ")[0] : "" }}</span>
            </div>
          </div>
          <div v-if="pageType === '规划审核负责人'">
            <van-field readonly v-model="!form.GHJBRJG ? '' : form.GHJBRJG == 48 ? '拟通过' : '不通过'" label="镇街规划审核(经办人)" />
            <van-field type="textarea" rows="3" readonly v-model="form.GHYJJBR" label="镇街规划审核结论(经办人)" />
            <div style="text-align: right;font-size: 14px;">
              <span style="margin-right: 10px">{{ form.ZJGHSHR }}</span>
              <span>{{ form.ZJGHSHSJ ? form.ZJGHSHSJ.split(" ")[0] : "" }}</span>
            </div>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field readonly clickable name="picker" v-model="!form.CS ? '' : form.CS == 9 ? '拟同意' : '不同意'" :label="'镇街1' +
                pageType.substring(0, 4) +
                '(' +
                pageType.substring(pageType.length - 3) +
                ')'
                " placeholder="请选择" @click="showPicker1 = true" />
            </div>
            <van-popup v-model="showPicker1" position="bottom" get-container="#popup">
              <van-picker show-toolbar :columns="columns4" @confirm="onConfirm" @cancel="showPicker1 = false" />
            </van-popup>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field type="textarea" rows="3" v-model="form.GHFZR" :label="'镇街' +
                pageType.substring(0, 4) +
                '结论(' +
                pageType.substring(pageType.length - 3) +
                ')'
                " placeholder="请输入" />
            </div>
            <div style="text-align: right;font-size: 14px;">
              <span style="margin-right: 10px">{{ userName }}</span>
              <span>{{ getDate() }}</span>
            </div>
          </div>
          <div v-if="pageType === '农房审核经办人'">
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field readonly clickable name="picker"
                v-model="!form.NFJBRJG ? '' : form.NFJBRJG == 48 ? '拟通过' : '不通过'" :label="'镇街' +
                  pageType.substring(0, 4) +
                  '(' +
                  pageType.substring(pageType.length - 3) +
                  ')'
                  " placeholder="请选择" @click="showPicker1 = true" />
            </div>
            <van-popup v-model="showPicker1" position="bottom" get-container="#popup">
              <van-picker show-toolbar :columns="columns1" @confirm="onConfirm" @cancel="showPicker1 = false" />
            </van-popup>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field type="textarea" rows="3" v-model="form.NFJBR" :label="'镇街' +
                pageType.substring(0, 4) +
                '结论(' +
                pageType.substring(pageType.length - 3) +
                ')'
                " placeholder="请输入" />
            </div>
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ userName }}</span>
              <span>{{ getDate() }}</span>
            </div>
            <van-field readonly v-model="!form.NFFZRJG ? '' : form.NFFZRJG == 9 ? '拟同意' : '不同意'" label="镇街农房审核(负责人)" />
            <van-field readonly type="textarea" rows="3" v-model="form.NFFZR" label="镇街农房审核结论(负责人)" />
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ form.ZJNFSHR2 }}</span>
              <span>{{ form.ZJNFSHSJ2 ? form.ZJNFSHSJ2.split(" ")[0] : "" }}</span>
            </div>
          </div>
          <div v-if="pageType === '农房审核负责人'">
            <van-field readonly v-model="!form.NFJBRJG ? '' : form.NFJBRJG == 48 ? '拟通过' : '不通过'" label="镇街农房审核(经办人)" />
            <van-field readonly type="textarea" rows="3" v-model="form.NFJBR" label="镇街农房审核结论(经办人)" />
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ form.ZJNFSHR }}</span>
              <span>{{ form.ZJNFSHSJ ? form.ZJNFSHSJ.split(" ")[0] : "" }}</span>
            </div>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field readonly clickable name="picker" v-model="!form.NFFZRJG ? '' : form.NFFZRJG == 9 ? '拟同意' : '不同意'"
                :label="'镇街' +
                  pageType.substring(0, 4) +
                  '(' +
                  pageType.substring(pageType.length - 3) +
                  ')'
                  " placeholder="请选择" @click="showPicker1 = true" />
            </div>
            <van-popup v-model="showPicker1" position="bottom" get-container="#popup">
              <van-picker show-toolbar :columns="columns4" @confirm="onConfirm" @cancel="showPicker1 = false" />
            </van-popup>
            <div class="inputWrap">
              <span style="color:red">*</span>
              <van-field type="textarea" rows="3" v-model="form.NFFZR" :label="'镇街' +
                pageType.substring(0, 4) +
                '结论(' +
                pageType.substring(pageType.length - 3) +
                ')'
                " placeholder="请输入" />
            </div>
            <div style="text-align: right">
              <span style="margin-right: 10px">{{ userName }}</span>
              <span>{{ getDate() }}</span>
            </div>
          </div>
          <div class="bottom">
            <van-button style="margin-right: 10px" size="small" type="info" @click="getinsertDataView">提交</van-button>
            <van-button style="margin-right: 10px" size="small" type="info" @click="save()">保存</van-button>
            <van-button size="small" type="info" @click="openMap()">地图</van-button>
          </div>
        </div>
      </van-tab>
      <van-tab title="过程信息">
        <FileData :ROW_GUID="form.ROW_GUID" :rowData="form"></FileData>
      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
import {
  QuerySignCallback,
  updateDataView,
  GetFileData,
  FileServerUpload,
  DelectFile,
  PlatSendTask,
  ExecProcedure,
  Atlases,
  dataTransFile,
  dataTransFilePreview,
  selectListByIds,
  Atlas,
  FileServerProxy
} from '@/utils/api'
import { Dialog } from 'vant'
import upLoad from '@/utils/upLoad'
import FramlyData from "./FramlyData.vue"
import lianjianrenGTXX from './lianjianrenGTXX.vue'
import FileData from '@/components/activity/FileData'
import { GSA_Add, GSA_Search } from '@/common/commonApi'
export default {
  data() {
    return {
      fileData: [
        {
          name: "图集示例图",
          groupGuid: "55f2a38f-085d-43e6-a999-d04bc49d2b0f",
          fileList: [],
        },
        {
          name: "图集文件(pdf)",
          groupGuid: "67097646-ddac-499e-811c-1511547d4c3d",
          fileList: [],
        },
        {
          name: "图集文件(cad)",
          groupGuid: "101ed989-32eb-4ed5-98ae-025f4f39f77d",
          fileList: [],
        },
      ],
      TXJSARR1: [],
      fileCUN: [

        {
          title: "农用地转用审批资料文件",
          groupGuid: "eaf00a19-63a3-466e-93cc-0b26cd031666",
          FileName: '无',
          fileList: [],
        },
        {
          title: "其他相关资料文件",
          FileName: '无',
          groupGuid: "18450870-ac41-4089-be09-f960b9bd37ab",
          fileList: [],
        },
      ],
      fileCUN1: [

        {
          title: "规划核查凭证资料规划",
          groupGuid: "d38cfe5a-b8c9-4b6f-81f2-e2f154f3ac4c",
          FileName: '无',
          fileList: [],
        },
        {
          title: "农用地转用审批资料规划",
          FileName: '无',
          groupGuid: "88bd54e3-6975-4f84-b1b7-8ca76a0b4264",
          fileList: [],
        },
        {
          title: "建设工程规划许可证",
          groupGuid: "cf301363-ae30-4421-b4bd-ef355eb447ed",
          FileName: '无',
          fileList: [],
        },
        {
          title: "宅基地坐落平面位置图",
          FileName: '无',
          groupGuid: "be6c2622-e00f-49ca-b59d-2550fa62fef6",
          fileList: [],
        },
        {
          title: "四邻意见书",
          groupGuid: "b2044faf-d609-46c5-995e-d9d2bab0af6d",
          FileName: '无',
          fileList: [],
        }
      ],
      fileCUN2: [

        {
          title: "在土地总体利用图上的位置图",
          groupGuid: "18412d03-0b7d-4da9-a38b-11dd9e2fe2ca",
          FileName: '无',
          fileList: [],
        },
        {
          title: "村庄规划图所在的位置图",
          FileName: '无',
          groupGuid: "1aecc69f-cb0b-4f9a-9d48-aeddf8227a91",
          fileList: [],
        },
      ],
      active: 0,
      tjwjpdf: "",
      tjwjcad: "",
      AtlasData: {},
      fileListID: [],
      userName: '',
      baseurlid: window.g.OSSPriviewId,
      showPicker1: false,
      value: '',
      columns: ['是', '否'],
      showPicker: false,
      tableData: [],
      tableData1: [
        {
          FAMILYNAME: '红线图'
        }
      ],
      form: {},
      formTKXX: {},
      formData: {},
      pageType: '',
      columns1: [
        { text: '拟通过', value: 48 },
        { text: '不通过', value: 49 }
      ],
      columns4: [
        { text: '拟同意', value: 9 },
        { text: '不同意', value: 10 }
      ],
      columns2: [
        { text: '乡、村规划区内', value: '66' },
        { text: '城镇建设用地范围', value: '67' }
      ],
      showPicker2: false,
      // GHFW: {},
      fileList: [],
      GJXX: {},
      TBJ: {},
      groupGuids: 'be6c2622-e00f-49ca-b59d-2550fa62fef6',
      TJData: {

        ROW_GUID: "",
        ID: '',
        ATLAS_NAME: '',
        AREA: '',
        BUILD_AREA: '',
        FLOORS: '',
        TJSJS: '',
        SJSSJH: '',
        CITYCODE: '',
        ATLAS_TYPE: 158
      },
      tableTJData: [],
      isAdd: true,
      TJBH: "",
      formDataYZDJ:{},
      ENUM: {
        XB: false,
        YDLX1: false,
        TXJS1: false,
        ZDJS1: false,
        XBARR1:false,
        ISSLYJ: false,
        XBARR: [],
        SF: false,
        SF1: false,
        SF2: false,
        SFGHQ:false,
        SFARR: [],
        NYD: false,
        NYDARR: [],
        JFLX: false,
        JFLXARR: [],
        YDLX: false,
        YDLXARR: [],
        JGLX: false,
        JGLXARR: [],
        WSCLFS: false,
        WSCLFSARR: [],
        TKBM: false,
        TKBMARR: [],
        CHBM: false,
        CHBMARR: [],
        YDLXARR1: [],
        TXJSARR1: [],
        ZDJCZRR1: [],
      },
    }
  },
  filters: {
    // inUseNameGHQ:function(msg,data){
    //   try {
    //     debugger
    //     let name = ''
    //     data.forEach((item) => {
    //       if (item.GHQKEY == msg) {
    //         name = item.GHQVALUE
    //       }
    //     })
    //     return name
    //   } catch (err) { }
    // },
    inUseName: function (msg, data) {

      try {
        let name = ''
        data.forEach((item) => {
          if (item.DICID == msg) {
            name = item.DICNAME
          }
        })
        return name
      } catch (err) { }
    },
    // inUseName1: function (msg, data) {
    //   try {
    //     let arr1 = []
    //     data.forEach((item) => {
    //       msg.forEach((items) => {
    //         if (item.DEPTID == items) {
    //           arr1.push(item.DEPT_NAME)
    //         }
    //       })
    //     })
    //     return arr1.join(',')
    //   } catch (err) { }
    // },
    // inUseName2: function (msg, data) {
    //   try {
    //     let arr1 = []
    //     data.forEach((item) => {
    //       msg.forEach((items) => {
    //         if (item.ST_ID == items) {
    //           arr1.push(item.ST_NAME)
    //         }
    //       })
    //     })
    //     return arr1.join(',')
    //   } catch (err) { }
    // }
  },
  methods: {
    // 上传图片
    getList() {

      this.groupGuids = "55f2a38f-085d-43e6-a999-d04bc49d2b0f";
    },
    //获取原宅基地信息
    async getJJDData() {
      let data = [
        {
          field: 'ROW_GUID',
          value: this.form.ROW_GUID
        }
      ]
      const res = await GSA_Search('7a676879-10c7-41eb-88c0-2beb7b111158', data)
      console.log(res, 'xiaohehua')
      this.formDataYZDJ = res.Data[0];
    },
    afterRead(file) {
      this.getFileServerUpload(file.file);
    },
    // delectFile: async function (file) {
    //   if (file.ROW_GUID) {
    //     const res = await DelectFile({
    //       fileGuid: file.ROW_GUID,
    //       token: window.localStorage.getItem("token"),
    //     });
    //   }
    // },
    delectFile: async function (file) {
      let fileguid = "";
      if (file.ROW_GUID) {
        fileguid = file.ROW_GUID;
      } else {
        fileguid = this.fileGuid;
      }
      if (fileguid) {
        let params = {
          accessCode: "ce9b691634de4ebca68dc5bb638d07f4",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: {
            fileGuid: fileguid,
            token: window.localStorage.getItem("token"),
          },
        };
        const res = await FileServerProxy(params);
        let data = JSON.parse(res.data.data).Success;
        if (data) {
          this.$toast.success("删除成功!");
        }
      }
    },
        //获取界面所需字典值
        getEnum: async function (viewID) {
      let _this = this
      // 86d6eb80-8bcb-49f6-b5c3-462ac1ae585d	是否
      // a8e5782d-9a59-48e4-b35b-654b9bb667ca	性别
      // db35edee-88e0-4fae-b14a-868ed4beb1d9   建房类型
      // d2ec96d4-b5bc-404a-a9f1-34db915c694b	用地类型
      // b65d1943-66f4-49b1-b759-cd9f079dc0d3	结构类型
      // let token = window.localStorage.getItem("token");
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: viewID,
          searchObject: JSON.stringify([]),
          token: window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(params)
      // this.listData = JSON.parse(res.data.data).Data;
      // const res = await dataServerOpenDataView(viewID, [], token);
      switch (viewID) {
        case '86d6eb80-8bcb-49f6-b5c3-462ac1ae585d':
          this.ENUM.SFARR = JSON.parse(res.data.data).Data
          this.ArrayErr = JSON.parse(res.data.data).Data
          break
        case 'db35edee-88e0-4fae-b14a-868ed4beb1d9':
          this.ENUM.JFLXARR = JSON.parse(res.data.data).Data
          break
        case '52215e71-341a-452b-8823-a8d4aae058ab':
          this.ENUM.NYDARR = JSON.parse(res.data.data).Data
          break
        case 'a8e5782d-9a59-48e4-b35b-654b9bb667ca':
          this.ENUM.XBARR = JSON.parse(res.data.data).Data
          // this.ENUM.XBARR.forEach((element) => {
          //   if (element.DICID == _this.formData.SEX) {
          //     _this.sexName = element.DICNAME
          //   }
          // })
          break
        case 'd2ec96d4-b5bc-404a-a9f1-34db915c694b':
          this.ENUM.YDLXARR = JSON.parse(res.data.data).Data
          break
        case 'b65d1943-66f4-49b1-b759-cd9f079dc0d3':
          this.ENUM.JGLXARR = JSON.parse(res.data.data).Data
          break
        case 'f7f359ad-369c-4bf4-892c-294dceb5edef':
          this.ENUM.WSCLFSARR = JSON.parse(res.data.data).Data
          break
        // case '63f488ed-f43d-4166-915b-71d7af7fed2f':
        //   this.ENUM.TKBMARR = JSON.parse(res.data.data).Data
        //   break
        // case 'd4d925da-cfd1-4608-94bb-24789720de0a':
        //   this.ENUM.CHBMARR = JSON.parse(res.data.data).Data
        //   break
        case '9b7e6eba-f7a0-4684-b820-8357dd92ae32':
          debugger
          this.ArrayErr1 = JSON.parse(res.data.data).Data
          break
        case 'a892e0f4-5fd6-42b4-b6c2-6e1fc5ebb5dc':
          this.ENUM.YDLXARR1 = JSON.parse(res.data.data).Data
          break
        case 'd9d4db60-e2f0-429f-b6c7-5cb1e9e6bb2d':
          debugger
          this.ENUM.TXJSARR1 = JSON.parse(res.data.data).Data
          break
        case '2c478392-9c1b-40da-b941-41e4b8c9d6d3':
          this.ENUM.ZDJCZRR1 = JSON.parse(res.data.data).Data
          break

        default:
          break
      }
    },
    // getFileServerUpload: async function (file) {
    //   let formData = new FormData();
    //   formData.append("file", file);
    //   formData.append("toRowGuid", this.rowGuid);
    //   formData.append("groupGuid", this.groupGuids);
    //   formData.append("token", window.localStorage.getItem("token"));
    //   const res = await drawImg(formData);
    //   if (res.data.Success == true) {
    //     this.$toast.success("上传成功!");
    //     this.fileData.forEach((item, index) => {
    //       item.fileList = [];
    //     });
    //     this.getFile();
    //   }
    // },
    openMap() {
      this.$router.push({
        path: '/mapContainer',
        query: {
          data: JSON.stringify(this.$route.query.data)
        }
      })
    },
    onOversize(file) {
      this.$toast.fail('文件大小不能超过 100kb!')
      // this.$notify({ type: 'error', message: '文件大小不能超过 100kb!' });
    },
    delectFile: async function (file) {
      let fileguid = "";
      if (file.ROW_GUID) {
        fileguid = file.ROW_GUID;
      } else {
        fileguid = this.fileGuid;
      }
      if (fileguid) {
        let params = {
          accessCode: "ce9b691634de4ebca68dc5bb638d07f4",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: {
            fileGuid: fileguid,
            token: window.localStorage.getItem("token"),
          },
        };
        const res = await FileServerProxy(params);
        let data = JSON.parse(res.data.data).Success;
        if (data) {
          this.$toast.success("删除成功!");
        }
      }
    },
    // delectFile: async function (file) {
    //   if (file.ROW_GUID) {
    //     const res = await DelectFile({
    //       fileGuid: file.ROW_GUID,
    //       token: window.localStorage.getItem('token')
    //     })
    //   }
    // },
    async handleG0toPDF(item) {
      if (item.atlasFile.pdfIds) {
        //根据id获取
        // const res = await selectListByIds(item.fileId)
        const res = await selectListByIds(item.atlasFile.pdfIds)
        this.tjwjpdf = res.data.data[0]
      } else {
        this.$toast.fail('暂无附件！')
        return
      }

    },
    async handleG0toDWG(item) {
      if (item.atlasFile.dwgIds) {
        //根据id获取
        // const res = await selectListByIds(item.fileId)
        const res = await selectListByIds(item.atlasFile.dwgIds)
        this.tjwjcad = res.data.data[0]
      } else {
        this.$toast.fail('暂无附件！')
        return
      }
    },
    afterRead(file) {
      // 此时可以自行将文件上传至服务器
      this.getFileServerUpload(file.file)
    },
    getFileServerUpload: async function (file) {
      ;
      let data = {
        toRowGuid: this.TJData.ROW_GUID,
        groupGuid: this.groupGuids,
        token: window.localStorage.getItem("token"),
      };
      let formData = new FormData();
      formData.append("file", file);
      formData.append("accessCode", "7a3fc061c866434b8475d3775c9ddcea");
      formData.append("cityCode", window.localStorage.getItem("citycode")
        ? window.localStorage.getItem("citycode")
        : "441300000000");
      formData.append("token", window.localStorage.getItem("token"));
      formData.append("paramStr", JSON.stringify(data));
      const res = await dataTransFile(formData);
      let data1 = JSON.parse(res.data.data).FileList;
      this.fileGuid = data1[0].FILEGUID;
      if (data1[0].FILEGUID) {
        this.$toast.success("上传成功!");
      }
      this.getFiles();
      // let formData = new FormData()
      // formData.append('file', file)
      // formData.append('toRowGuid', this.rowGuid)
      // formData.append('groupGuid', this.groupGuids)
      // formData.append('token', window.localStorage.getItem('token'))
      // const res = await FileServerUpload(formData)
      // if (res.data.Success == true) {
      //   this.$toast.success('上传成功!')
      //   // this.$notify({ type: 'success', message: '上传成功!' });
      // }
    },
    onConfirm1(data) {
      // this.GHFW = data;
      this.showPicker = false
      switch (data.value) {
        case '67':
          this.form.GHFWLX = data.value
          break
        case '66':
          this.form.GHFWLX = data.value
          break
      }
    },
    onConfirm(data) {
      switch (this.pageType) {
        case '资格审核经办人':
          this.form.ZJZGSHJG = data.value
          break
        case '资格审核负责人':
          this.form.ZJZGSH = data.value
          break
        case '规划审核经办人':
          this.form.GHJBRJG = data.value

          break
        case '规划审核负责人':
          this.form.CS = data.value
          break
        case '农房审核经办人':
          this.form.NFJBRJG = data.value
          break
        case '农房审核负责人':
          this.form.NFFZRJG = data.value
          break
      }
      this.showPicker1 = false
    },
    getAtlas: async function () {
      let dataGuid = '4a9869f7-eb64-4a88-9d67-1e43455d3220'
      let searchObject = JSON.stringify([{ field: 'to_row_guid', value: this.form.ROW_GUID, operator: '=' }])
      let parms = {
        dataGuid: dataGuid,
        searchObject: searchObject,
        //token: window.localStorage.getItem('token')
      }
      let params1 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',

        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: parms
      }
      const res = await QuerySignCallback(params1)
      this.GJXX = eval('(' + res.data.data + ')').Data[0]
    },
    //图集查看
    seeAtlas: async function () {

      let params = {
        accessCode: "29ff26f660fc47f79c15bff382eeca6d",
        cityCode: window.localStorage.getItem('citycodeChange') ? window.localStorage.getItem('citycodeChange') : '441300000000',
        id: this.GJXX.TJBH
      }
      const res = await Atlas(params)
      if (res.data.data) {
        debugger
        this.$router.push({
          path: '/PhotoThreePage',
          query: {
            data: res.data.data
          }
        })
      }
      else {
        this.$toast.fail(res.data.msg)
      }
      // this.$router.push({
      //   path: '/PhotoThreePage',
      //   query: {
      //     data1: {
      //       data: res.data.data.pageList[0],
      //       atlasId: this.GJXX.TJBH
      //     }
      //   }
      // })
      // let params = {
      //   accessCode: '29ff26f660fc47f79c15bff382eeca6d',
      //
      //   pageNo: 1,
      //   pageSize: 1,
      //   atlasId: this.GJXX.TJBH
      // }
      // const res = await Atlas(params)
      // this.$router.push({
      //   path: '/PhotoThreePage',
      //   query: {
      //     data1: {
      //       data: res.data.data.pageList[0],
      //       atlasId: this.GJXX.TJBH
      //     }
      //   }
      // })
    },
    //选择通用图集
    selectAtlas(){
     debugger
     window.sessionStorage.setItem("IsZZDZJSH",true);
     window.sessionStorage.setItem("formDataZJ",this.$route.query.data);
     this.$router.push({
            path: '/BuildingServer',
            query: {
              id: 'ChooseCraftsmanZJ',
              data:this.form,
              data11: '1'
            }
          })
    },
    getXianOpenDataView: async function () {
      let dataGuid = '2c478392-9c1b-40da-b941-41e4b8c9d6d3'
      let searchObject = []
      let parms = {
        dataGuid: dataGuid,
        searchObject: searchObject,
        //token: window.localStorage.getItem('token')
      }
      let params1 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',

        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: parms
      }
      const res = await QuerySignCallback(params1)
      if (eval('(' + res.data.data + ')').Data) {
        eval('(' + res.data.data + ')').Data.forEach((item, index) => {
          if (this.form.XZJDCZQK == item.DICID) {
            this.form.XZJDCZQK = item.DICNAME
          }
        })
      }
      // this.formData.STRUCTURETYPE
    },
    async getTJBH(){

    },
    getinsertDataView: async function () {
      debugger
        //先判断是否已上传图集
      if(this.pageType=='农房审核经办人'&&!this.GJXX.TJBH){
        Dialog.confirm({
          message: `系统监测到当前案卷未上传图集,是否继续提交?`,
        }).then(async () => {
          this.save('Submit')
        })
          .catch(() => {
           this.$toast.fail("请上传图集!")
          });

      }else{
        this.save('Submit')

      }

    },
    handleGoToNext: async function () {
      debugger
      //判断
      let paer = {}
      //判断当前是哪个审批环节  根据不同的审批环节更新不同值
      if (this.$route.query.data.NODE_GUID == '{646A4D45-00AC-4EA9-98AE-C5E704740BC1}') {
        paer = {
          procName: 'cs_xgzjsfh',
          dtParams: JSON.stringify([
            {
              I_PROC_GUID: this.form.PROC_GUID,
              I_TYPE: 52,
              I_ROW_GUID: this.form.ROW_GUID,
              I_PKID: this.form.PKID
            }
          ])
        }
        let procNameAuto = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "",
          params: paer,
        };
        const res = await FileServerProxy(procNameAuto);
      } else if (this.$route.query.data.NODE_GUID == '{D9C76DDF-7A07-4F5F-A9F2-FD597C715481}') {
        paer = {
          procName: 'cs_xgzjsfh',
          dtParams: JSON.stringify([
            {
              I_PROC_GUID: this.form.PROC_GUID,
              I_TYPE: 53,
              I_ROW_GUID: this.form.ROW_GUID,
              I_PKID: this.form.PKID
            }
          ])
        }
        let procNameAuto = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "",
          params: paer,
        };
        const res = await FileServerProxy(procNameAuto);
      } else if ((this.$route.query.data.NODE_GUID == '{BFF3BE52-75D4-4C53-B5E9-9144E35E7617}')) {
        paer = {
          procName: 'cs_xgzjsfh',
          dtParams: JSON.stringify([
            {
              I_PROC_GUID: this.form.PROC_GUID,
              I_TYPE: 54,
              I_ROW_GUID: this.form.ROW_GUID,
              I_PKID: this.form.PKID
            }
          ])
        }
        let procNameAuto = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "",
          params: paer,
        };
        const res = await FileServerProxy(procNameAuto);
      }
      // let paerauto = {
      //     procName: "up_query",
      //     dtParams: JSON.stringify([{ I_USERID: stre, I_TYPE: 2 }]),
      //     token: window.localStorage.getItem("token"),
      //   };

    },
    getNowTime: function () {
      let dateTime
      let yy = new Date().getFullYear()
      let mm = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1
      let dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
      let hh = new Date().getHours()
      let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
      let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
      dateTime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss
      return dateTime
    },
    getDate: function () {
      let dateTime
      let yy = new Date().getFullYear()
      let mm = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1
      let dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
      let hh = new Date().getHours()
      let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
      let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
      dateTime = yy + '-' + mm + '-' + dd
      return dateTime
    },
    getuuid() {

      function S4() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
      }
      function guid() {
        return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
      }
      return guid();
    },
    // 保存
    save: async function (type) {
      if (this.TJBH == 158) {
        this.saveTJData();
      }

      let data = {}
      let userName = JSON.parse(window.localStorage.getItem('userName')).userName ? JSON.parse(window.localStorage.getItem('userName')).userName : window.localStorage.getItem('userName') ? window.localStorage.getItem('userName') : ""
      switch (this.pageType) {
        case '资格审核经办人':
          data.YJ = this.form.YJ
          data.ZJZGSHJG = this.form.ZJZGSHJG
          data.ZJZGSHSJ = this.getNowTime()
          data.ZJZGSHR = userName
          break
        case '资格审核负责人':
          data.ZJZGSHYJFZR = this.form.ZJZGSHYJFZR
          data.ZJZGSH = this.form.ZJZGSH
          data.ZJZGSHSJ2 = this.getNowTime()
          data.ZJZGSHR2 = userName
          break
        case '规划审核经办人':
          data.GHYJJBR = this.form.GHYJJBR
          data.GHJBRJG = this.form.GHJBRJG
          data.ZJGHSHSJ = this.getNowTime()
          data.ZJGHSHR = userName
          data.GHFWLX = this.form.GHFWLX
          break
        case '规划审核负责人':
          data.CS = this.form.CS
          data.GHFZR = this.form.GHFZR
          data.ZJGHSHSJ2 = this.getNowTime()
          data.ZJGHSHR2 = userName
          break
        case '农房审核经办人':
          data.NFJBRJG = this.form.NFJBRJG
          data.NFJBR = this.form.NFJBR
          data.ZJNFSHSJ = this.getNowTime()
          data.ZJNFSHR = userName
          break
        case '农房审核负责人':
          data.NFFZRJG = this.form.NFFZRJG
          data.NFFZR = this.form.NFFZR
          data.ZJNFSHSJ2 = this.getNowTime()
          data.ZJNFSHR2 = userName
          break
      }
      data.PKID = this.form.PKID
      data.ROW_GUID = this.form.ROW_GUID
      let status = true
      for (var i in data) {
        if (!data[i]) {
          status = false
        }
      }
      if (status) {
        let params = {
          accessCode: "77ad6c1591e54d4fbc45ecc90374a2a2",
          cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
          params: {
            dataGuid: '1011b0e4-f9e4-4cad-977b-96be16f90ac3',
            strParams: JSON.stringify([data]),
          },
        };
        const res = await QuerySignCallback(params);
        if (JSON.parse(res.data.data).Success) {
          if (type) {
            this.$router.push({
              path: '/TreeSelect1',
              query: { data: this.form, iszjsh: 1 }
            })
            this.handleGoToNext()
          } else {
            this.$toast.success('保存成功!')
          }
          // this.$notify({ type: 'success', message: '保存成功!' });
        }
      } else {
        this.$toast.fail('请输入必填项!')
      }
    },
    //获取附件材料1223
    getFiles: async function () {
      let me = this;
      let groupGuid = []
      me.fileData.forEach(item => {
        groupGuid.push(item.groupGuid)
      })
      let params = {
        accessCode: "1fdcbce42c6d4748a020feba618d54b8",
        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000",
        params: {
          groupGuid: groupGuid.join(","),
          toRowGuid: me.TJData.ROW_GUID,
          token: window.localStorage.getItem('token')
        },
      };
      const res1 = await FileServerProxy(params);
      let ress = JSON.parse(res1.data.data)
      if (ress.FilesInfo.length > 0) {
        ress.FilesInfo.forEach(element => {
          me.fileData.forEach(item => {
            if (element.GROUPGUID == item.groupGuid) {
              me.getFileUrl(element, item);
              // element['file'] = {
              //   name: element.FILENAME
              // }
              // element['url'] =
              //   window.g.BaseURL +
              //   'FileServer/api/Preview?token=' +
              //   window.localStorage.getItem('token') +
              //   '&' +
              //   'fileGuid=' +
              //   encodeURIComponent(element.ROW_GUID)
              // item.fileList.push(element)
            }
          })
        })
      }

    },

    //获取相关材料
    getFile: async function () {

      let dataGuid = 'a0e224e8-36be-4591-b770-30cabda3514a'
      let searchObject = JSON.stringify([{ field: 'to_row_guid', value: this.TJData.ROW_GUID, operator: '=' }])
      let parms = {
        dataGuid: dataGuid,
        searchObject: searchObject,
        //token: window.localStorage.getItem('token')
      }
      let params1 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: parms
      }
      const res = await QuerySignCallback(params1)
      this.isSaveFile = true
      if (eval('(' + res.data.data + ')').Data.length > 0) {
        this.rowGuid = eval('(' + res.data.data + ')').Data[0].ROW_GUID
        let groupGuid = []
        this.isSaveFile = false
        // this.fileData.forEach(item => {
        //   groupGuid.push(item.groupGuid)
        // })
        let params1 = {
          "accessCode": "1fdcbce42c6d4748a020feba618d54b8",
          "cityCode": window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
          "params": {
            "groupGuid": this.groupGuids,
            "toRowGuid": this.rowGuid,
            // token: window.localStorage.getItem('token')
          }
        }
        const res1 = await QuerySignCallback(params1)
        let data = JSON.parse(res1.data.data).FilesInfo
        if (data.length > 0) {
          data.forEach(element => {
            this.getFileUrl(element, "");
            // // this.fileData.forEach(item => {
            // //   if (element.GROUPGUID == item.groupGuid) {
            // element['isImage'] = true
            // element['url'] =
            //   window.g.BaseURL +
            //   'FileServer/api/Preview?token=' +
            //   window.localStorage.getItem('token') +
            //   '&' +
            //   'fileGuid=' +
            //   encodeURIComponent(element.ROW_GUID)
            // this.fileList.push(element)
            // // }
            // // })
          })
        }
      }
    },
    //获取附件文件流
    getFileUrl: async function (element, item) {

      let formData = new FormData();
      formData.append("accessCode", "98bcf528966e48ce896a8b3fd02d45d5");
      formData.append(
        "cityCode",
        window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000"
      );
      formData.append(
        "paramStr",
        JSON.stringify({
          fileGuid: element.ROW_GUID,
        })
      );
      let response = await dataTransFilePreview(formData);
      if (response) {
        var img = new Blob([new Int8Array(response.data, 0)], {
          type: response.headers["content-type"],
        }); //type类型可自定义
        element["isImage"] = true;
        element["url"] = window.URL.createObjectURL(img);
        if (item.groupGuid == "55f2a38f-085d-43e6-a999-d04bc49d2b0f") {

          this.fileList.push(element)

        }
        if (item.groupGuid == "67097646-ddac-499e-811c-1511547d4c3d") {
          this.tjwjpdf = element.FILENAME;
        }
        if (item.groupGuid == "101ed989-32eb-4ed5-98ae-025f4f39f77d") {
          this.tjwjcad = element.FILENAME;
        }
        else if (item) {
          item.fileList.push(element);
        } else {
          this.fileList.push(element)
        }

      }
    },
    //获取踏勘信息
    GetTKXXData: async function () {
      let dataGuid = 'a0e224e8-36be-4591-b770-30cabda3514a'
      let searchObject = JSON.stringify([{ field: 'to_row_guid', value: this.form.ROW_GUID, operator: '=' }])
      let parms = {
        dataGuid: dataGuid,
        searchObject: searchObject,
        //token: window.localStorage.getItem('token')
      }
      let params1 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',

        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: parms
      }
      const res = await QuerySignCallback(params1);
      let resData = JSON.parse(res.data.data);

      if (resData.Data && resData.Data.length > 0) {
        this.formTKXX = resData.Data[0];
        this.pageTypefile()
        this.formTKXX.HOMESTEADAREA = resData.Data[0].HOMESTEADAREA
      }

    },
    pageTypefile() {
      switch (this.pageType) {
        case '资格审核经办人':
          if (this.form.YJ != '' || this.form.YJ != null || this.form.YJ) {
            this.form.YJ =
              '该户符合“一户一宅”标准，符合宅基地申请资格条件，可申请的宅基地面积为' + this.formTKXX.HOMESTEADAREA + 'm²，拟同意上报审批。'
          }

          break
        case '资格审核负责人':
          if (this.form.ZJZGSHYJFZR != '') {
            this.form.ZJZGSHYJFZR =
              '该户符合“一户一宅”标准，符合宅基地申请资格条件，可申请的宅基地面积为' + this.formTKXX.HOMESTEADAREA + 'm²，拟同意上报审批。'
          }

          break
        case '规划审核经办人':
          if (this.form.GHYJJBR != '') {
            this.form.GHYJJBR = '该户拟用地符合国土空间规划（含土地利用规划和城乡规划），拟同意上报审批。'
          }

          break
        case '规划审核负责人':
          if (this.form.GHFZR != '') {
            this.form.GHFZR = '该户拟用地符合国土空间规划（含土地利用规划和城乡规划），拟同意上报审批。'
          }

          break
        case '农房审核经办人':
          if (this.form.NFJBR != '') {
            this.form.NFJBR = '该户已提交农村住房设计方案并图纸，符合相关要求，拟同意上报审批。'
          }

          break
        case '农房审核负责人':
          if (this.form.NFFZR != '') {
            this.form.NFFZR = '该户已提交农村住房设计方案并图纸，符合相关要求，拟同意上报审批。'
            break
          }
      }
    },
    //获取图集信息数据158
    getData: async function () {

      let dataguid = '3c6d947a-7b5c-4df7-99d3-f87c9a16963c'
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: '441300000000',
        params: {
          dataguid: dataguid,
          searchObject: JSON.stringify([{ field: "to_row_guid", value: this.form.ROW_GUID, operator: "=" }]),
          token: window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(params)
      let data = JSON.parse(res.data.data).Data[0]
      if (data) {
        this.tableTJData = data;
        this.isAdd = false
        for (let i in this.TJData) {
          this.TJData[i] = data[i]
        }
      } else {
        this.isAdd = true
        this.TJData.ROW_GUID = this.getuuid();
        if (this.form.BUILDTYPE == 14) {
          this.TJData.CITYCODE = this.form.XCITYCODE
        } else {
          this.TJData.CITYCODE = this.form.X
        }
        let CITYCODE = ''
        let declaerCode = '';//编号变量
        let curTime = new Date().getFullYear();//年
        CITYCODE = this.TJData.CITYCODE//行政区划编码
        let code = "zc-" + CITYCODE + "-" + curTime;//默认编码
        var arr = code.split("-");
        var to_ajh = arr[0] + "-" + arr[1] + "-" + arr[2];
        var stre = "'%" + to_ajh + "%'"
        let paerauto = {
          procName: "up_query",
          dtParams: JSON.stringify([{ I_USERID: stre, I_TYPE: 2 }]),
          token: window.localStorage.getItem("token"),
        };
        let procNameAuto = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: paerauto,
        };
        const res = await FileServerProxy(procNameAuto);
        let jsonres = JSON.parse(res.data.data);
        if (jsonres.Data && jsonres.Data.length > 0) {
          var str = jsonres.Data[0].ID;
          var arr = str.split("-");
          var ajh = arr[3];
          var a = (parseInt(ajh) + 1).toString();
          if (a.length == 1) {
            a = "000" + a;
          }
          if (a.length == 2) {
            a = "00" + a;
          }
          if (a.length == 2) {
            a = "0" + a;
          }
          if (a.length == 4) {
            a = a;
          }
          this.TJData.ID = to_ajh + '-' + a;

        } else {
          this.TJData.ID = to_ajh + '-' + "0001";
        }
      }
      this.getFiles();
    },
    saveTJData: async function () {

      //this.$refs.JDJGPDF.save()
      let data = this.TJData
      let accessCode = ''
      let dataGuid = "3c6d947a-7b5c-4df7-99d3-f87c9a16963c"
      data.TO_ROW_GUID = this.form.ROW_GUID
      if (this.isAdd) {
        accessCode = '0fb3f6123d1b4fe6851c99532c463f6f'
      } else {
        data.ID = data.ID
        data.PKID = this.tableTJData.PKID;
        accessCode = '77ad6c1591e54d4fbc45ecc90374a2a2'
      }
      let params = {
        dataGuid: dataGuid,
        strParams: JSON.stringify([data]),
        token: window.localStorage.getItem('token')
      }
      let params1 = {
        accessCode: accessCode,
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '',
        params: params
      }
      const res = await QuerySignCallback(params1)
      if (eval('(' + res.data.data + ')').Success == true) {
        this.$toast.success('成功！')
      } else {
        this.$toast.fail('失败！')
      }
    },
    getCode: async function () {
      // let paerauto = {
      //   procName: "up_query",
      //   dtParams: JSON.stringify([{ I_USERID: "'" + this.form.ROW_GUID + "'", I_TYPE: 1 }]),
      //   token: window.localStorage.getItem("token"),
      // };
      // let procNameAuto = {
      //   accessCode: "69db6bece3a7480592e2ec753d1e335e",
      //   cityCode: window.localStorage.getItem("citycode")
      //     ? window.localStorage.getItem("citycode")
      //     : "441300000000",
      //   params: paerauto,
      // };
      // const res = await FileServerProxy(procNameAuto);
      // let cres = JSON.parse(res.data.data);
      // if (cres.Data && cres.Data.length > 0) {
      //   console.log(cres.Data[0].TJLX,'kikkkkk')
      //   this.TJBH = cres.Data[0].TJLX;
      // }
      //吕川重写了
      let data = [{ field: "to_row_guid", value: this.form.ROW_GUID }]
      const res = await GSA_Search('4a9869f7-eb64-4a88-9d67-1e43455d3220', data)
      console.log(res, 'dufnui')
      if (res.Data.length > 0) {
        //用这个获取回显图集
        this.TJBH = res.Data[0].TJLX;
        if (this.TJBH) {
          this.getTJPhoto()
        }
        this.TJData = res.Data[0]
      }

    },
    //获取图集id
    async getTJPhoto() {
      let params = {
        accessCode: "29ff26f660fc47f79c15bff382eeca6d",
        cityCode: window.localStorage.getItem("citycode"),
        id: this.TJBH
      };
      const res = await Atlas(params);
      this.AtlasData = res.data.data;
      this.handleG0toPDF(this.AtlasData)
      this.handleG0toDWG(this.AtlasData)
    },
    openUrl() {
      window.open(this.baseurlid + this.tjwjpdf.fileId)
    },
    //获取缩略图
    async getSLT() {

    },
    //上传pdf或者cad
    uploadFilepdf(file) {
      //pdf
      var groupGuid = "67097646-ddac-499e-811c-1511547d4c3d";
      this.uploadFileAll1(file, groupGuid);
    },
    //上传cad
    uploadFilecad(file) {
      var groupGuid = "101ed989-32eb-4ed5-98ae-025f4f39f77d";
      this.uploadFileAll1(file, groupGuid);
    },
    handleAvatarSuccess() { },
    beforeAvatarUpload() { },
    uploadFileAll1: async function (file, groupGuid) {
      let me = this;
      let data = {
        toRowGuid: me.TJData.ROW_GUID,
        groupGuid: groupGuid,
        token: window.localStorage.getItem("token"),
      };
      let formData = new FormData();
      formData.append("file", file.file);
      formData.append("accessCode", "7a3fc061c866434b8475d3775c9ddcea");
      formData.append(
        "cityCode",
        window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000"
      );
      formData.append("paramStr", JSON.stringify(data));
      const res = await dataTransFile(formData);
      let data1 = JSON.parse(res.data.data).FileList;
      if (data1) {
        if (groupGuid == "101ed989-32eb-4ed5-98ae-025f4f39f77d") {
          this.tjwjcad = data1[0].FILENAME;
        }
        if (groupGuid == "67097646-ddac-499e-811c-1511547d4c3d") {
          this.tjwjpdf = data1[0].FILENAME;
        }

        this.$toast.success("上传成功");
        this.fileListID = data1;
      } else {
        this.$toast.fail("上传失败");
      }
    },
  },
  mounted() {
    //wjh 2022-04-08 三个经办人环节需要看踏勘信息的数据
    debugger
    // window.sessionStorage.setItem("formDataZJ",this.$route.query.data);
    if(this.$route.query.data){
      this.form = JSON.parse(this.$route.query.data)
    }
    // if(window.sessionStorage.getItem("formDataZJ")){
    //   this.form =JSON.parse(window.sessionStorage.getItem("formDataZJ"))
    // }
   //?JSON.parse(this.$route.query.data):JSON.parse(window.sessionStorage.getItem(""))
    //this.getList();
    // if(this.$store&&this.$store.state&&this.$store.state.JFTZ){
    //   this.GJXX=this.$store.state.JFTZ;
    // }
    this.getCode()
    this.getData()
    this.rowGuid = this.newGuid()
    this.userName = JSON.parse(window.localStorage.getItem('userName')).userName
    this.getFile()
    this.getAtlas()
    this.pageType = this.$route.query.type
    this.pageTypefile()
    this.getXianOpenDataView()
    //获取踏勘环节数据
    this.GetTKXXData();
    //获取原宅基地
    this.getJJDData();
    this.getEnum('d9d4db60-e2f0-429f-b6c7-5cb1e9e6bb2d');
    this.getEnum('a892e0f4-5fd6-42b4-b6c2-6e1fc5ebb5dc');
    //this.getFiles();
    // this.form.XZJDCZQK =
  },
  components: {
    FileData,
    lianjianrenGTXX,
    upLoad,
    FramlyData
  }
}
</script>
<style lang="scss" scoped>
#HandlerPage {

  /*.van-field__control {*/
  /*text-align: right !important;*/
  /*}*/
  .van-field__label {
    font-weight: bold;
  }

  height: 93vh;
  overflow: auto;

  .title {
    width: 100%;
    height: 50px;
    line-height: 50px;
    font-size: 20px;
    position: relative;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #9b9b9b;
    padding-left: 10px;

    .line {
      width: 6px;
      height: 26px;
      background: #3f8ffc;
      display: inline-block;
      margin-right: 10px;
    }
  }

  .bottom {
    padding: 10px;
    text-align: center;
  }

  .inputWrap {
    width: 100%;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid #ebedf0;
    padding: 0 16px;

    span {
      margin-right: 5px;
      margin-top: 15px;
    }

    .van-cell {
      padding: 10px 0 !important;
    }
  }
}
</style>


<style>
#HandlerPage .van-field__label {
  width: 8em;
}

#HandlerPage .van-field__control {
  text-align: right;
}
</style>
